package Algorithm.SortAlgorithmDome;

/**
 * ClassName:RecursionSort002
 * Package:Algorithm.SortAlgorithmDome
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/4-13:36
 * @Version:v1.0
 */
public class RecursionSort002 {
    /*需求：用递归求5的阶乘*/
    //方法内部再次调用方法的时候,参数必须要更加的靠近出口
    public static void main(String[] args) {
        getFactorial(5);
        System.out.println("5的阶乘:" + getFactorial(5));
    }

    private static int getFactorial(int number) {
        if (number == 1) {
            return 1;
        }
        return number * getFactorial(number - 1);
    }
}
